﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;
using System.Collections.ObjectModel;

namespace Freshome.m.mds
{
    // Minoraw type
    public class Minoraw : Shortype<Rmt.Minoraw>
    {
        public Minoraw(Rmt.Minoraw pm)
            : base(pm)
        {
        }
        public string Name
        {
            get { return this._pm.Name; }
            set
            {
                value = value.Trim();
                if (value.Match(@"^[\S\s]{2,10}$") && this._pm.Name != value)
                {
                    this._pm.Name = value;
                    this.Updated = !Created;
                }
                OnPropertyChanged("Name");
            }
        }
        public override void Refresh(Rmt.Minoraw pm)
        {
            this.Name = pm.Name;
            this.Notes = pm.Notes;
            this.Updated = false;
        }
        public bool IsValid
        {
            get
            {
                return _pm.Name.Match(@"^[\S\s]{2,10}$") && _pm.Notes.Match(@"^[\S\s]{0,50}$");
            }
        }
    }
    public sealed class SolidMaterial : Minoraw
    {
        public SolidMaterial()
            : this(new Rmt.Minoraw { Mid = default(short), Name = string.Empty, Category = Rmt.MinorawCateg.Solid })
        {
            _pm.Notes = string.Empty;
        }
        public SolidMaterial(Rmt.Minoraw pm)
            : base(pm)
        {
        }
    }
    public sealed class LiquidMaterial : Minoraw
    {
        public LiquidMaterial()
            : this(new Rmt.Minoraw { Mid = default(short), Name = string.Empty, Category = Rmt.MinorawCateg.Liquid })
        {
            _pm.Notes = string.Empty;
        }
        public LiquidMaterial(Rmt.Minoraw pm)
            : base(pm)
        {
        }
    }
}
